#!/usr/bin/env bash
dt="`date -d "$d  0 days ago "  "+%Y-%m-%d"`"
mysql -ureadonly -preadonly -h192.168.0.50<<EOF
use jiayou;
select id,
case
when enterprise_id = 5 then '承德'
when enterprise_id = 6 then '北京'
else null end as enterprise_id,
coupon_title,from_unixtime(created,'%Y-%m-%d'),from_unixtime(updated,'%Y-%m-%d'),
tactics_type,
case
when coupon_type = 1 then '燃油满减券'
when coupon_type = 2 then '燃油折扣券'
when coupon_type = 3 then '非油满减券'
else null end as coupon_type,
discount_amount,use_shop_id,
case
when coupon_statue = 1 then '可用'
when coupon_statue = 3 then '已使用'
when coupon_statue = 9 then '已过期'
else null end as coupon_statue
from coupon_info where coupon_type != 99 and from_unixtime(updated,'%Y-%m-%d %H')>='$dt';
EOF